//package dk.sdu.mmmi.AOP;

import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.core.Runtime;

import jade.tools.rma.rma;
import jade.wrapper.AgentController;
import jade.wrapper.ContainerController;
import jade.wrapper.StaleProxyException;

public class StartAgentPlatform {

	/**
	 * @param args
	 */
	
	public static void main(String[] args) {
		@SuppressWarnings("unused")
		String host = "localhost";
		String port = "";
		String name = "AOP";
		
		ContainerController cController;
		Runtime rt = Runtime.instance();//retrieve the singleton instance of the JADE Runtime
		Profile p;
		
		//Create a container
		p = new ProfileImpl();
		cController = rt.createMainContainer(p);			
		rt.setCloseVM(true);
		
		
		
		if(cController != null){
			try{
				//start GUI interface Agent
				AgentController ac = cController.createNewAgent("gui", rma.class.getName(), null);
				ac.start();
				
				//---add Agents in this zone---
				
				//add Agent main - trigger communications
				CreateAgent(cController, "Agent 007","HelloWorldAgent");
				/*
				//add Agent - receive acl msg and printout
				CreateAgent(cController, "pong1","dk.sdu.mmmi.AOP.Agents.Receiver");
				//add Agent - receive acl msg, printout and reply
				CreateAgent(cController, "pong2","dk.sdu.mmmi.AOP.Agents.Pong");
				
				//add Agent - register agent into DF, receive acl msg, printout and reply
				CreateAgent(cController, "pong","dk.sdu.mmmi.AOP.Agents.PingAgent");
				*/
				
			}
			catch (Exception e){
				e.printStackTrace();
			}
		}	
	}
	
	private static void CreateAgent(ContainerController cController, String agent_name, String agent_class) throws StaleProxyException{
		//add Agent AgentSender
		AgentController ac = cController.createNewAgent(agent_name, agent_class, null);
		ac.start();
	}
}
